﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Search
{
    public partial class frmSearch : UTLBASEFORM.MDICHILD
    {
        TSearch tSearch = new TSearch();
        public frmSearch()
        {
            InitializeComponent();
        }

        private void SearchProduct_Load(object sender, EventArgs e)
        {
            SetupMenuBar();
            panNV.Visible = false;
            panSP.Visible = true;
           
        }
        private void SetupMenuBar()
        {

            ShowBTN1("Tìm sản phẩm", null);
            ShowBTN2("Tìm nhân viên", null);
        }
        public override void btn1_Click(object sender, EventArgs e)
        {
            panNV.Visible = false;
            panSP.Visible = true;
        }
        public override void btn2_Click(object sender, EventArgs e)
        {
            panNV.Visible = true;
            panSP.Visible = false;
        }
        public void SearchEmplyee(string user) {
            int i=0;
            if (cmbFind.Text.Trim() == "Tên ĐN")
                i = 0;
            else i = 1;
            DataTable data = tSearch.SelectSearch(i,user);
            gvResult.DataSource = data;
        }
        private void buttonX1_Click(object sender, EventArgs e)
        {
            gvResult.Columns.Clear();
            SearchEmplyee(txtName.Text);
        }
        public void SearchPro(string barcode) {
            DataTable data = tSearch.SelectSearchProduct(barcode);
            gvResult.DataSource = data;
        }
        private void buttonX2_Click(object sender, EventArgs e)
        {
            gvResult.Columns.Clear();
            SearchPro(txtName2.Text);
        }
    }
}